cmake_minimum_required(VERSION  3.0.0)

################################################################################
#########################  set up cross compiler toolchain  ####################
################################################################################
include(${CMAKE_SOURCE_DIR}/project/${USER_PROJECT}/gcc/gcc-arm-none-eabi.cmake)

################################################################################
###########################  project language selection   ######################
################################################################################
project(${USER_PROJECT}
    VERSION    1.0.0
    LANGUAGES  C  ASM
)

################################################################################
##############################  Debug/Release  #################################
################################################################################
# set(CMAKE_BUILD_TYPE Release) # default value is Debug.

if(NOT  CMAKE_BUILD_TYPE)
  set(CMAKE_BUILD_TYPE  Debug)
endif(NOT  CMAKE_BUILD_TYPE)

message(STATUS  "Build type: ${CMAKE_BUILD_TYPE}")

################################################################################
#############################   misc settings   ################################
################################################################################

#-------------------------------   output path   -------------------------------
set(EXECUTABLE_OUTPUT_PATH    ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH       ${CMAKE_BINARY_DIR}/lib)

#----------------------------   project output elf   ---------------------------
set(TARGET_ELF_NAME  ${PROJECT_NAME}.elf)

################################################################################
###########################   define module top dir   ##########################
################################################################################
set(MCU_LN882X_DIR        ${CMAKE_SOURCE_DIR}/mcu)
set(COMP_FOTA_DIR         ${CMAKE_SOURCE_DIR}/components/fota)
set(COMP_KV_DIR           ${CMAKE_SOURCE_DIR}/components/fs/kv)
set(COMP_NVDS_DIR         ${CMAKE_SOURCE_DIR}/components/fs/nvds)
set(COMP_PARTMGR_DIR      ${CMAKE_SOURCE_DIR}/components/fs/partition_mgr)
set(COMP_KERNEL_DIR       ${CMAKE_SOURCE_DIR}/components/kernel)
set(COMP_DHCPD_DIR        ${CMAKE_SOURCE_DIR}/components/net/dhcpd)
set(COMP_HTTPSCLIENT_DIR  ${CMAKE_SOURCE_DIR}/components/net/httpsclient)
set(COMP_IPERF_DIR        ${CMAKE_SOURCE_DIR}/components/net/iperf)
set(COMP_LWIP_DIR         ${CMAKE_SOURCE_DIR}/components/net/lwip-2.0.3/src)
set(COMP_MBEDTLS_DIR      ${CMAKE_SOURCE_DIR}/components/net/mbedtls)
set(COMP_PING_DIR         ${CMAKE_SOURCE_DIR}/components/net/ping)
set(COMP_SERIAL_DIR       ${CMAKE_SOURCE_DIR}/components/serial)
set(COMP_AIRKISS_DIR      ${CMAKE_SOURCE_DIR}/components/smartlink/airkiss)
set(COMP_SMARTCFG_DIR     ${CMAKE_SOURCE_DIR}/components/smartlink/smartcfg)
set(COMP_SOFTAPCFG_DIR    ${CMAKE_SOURCE_DIR}/components/smartlink/softapcfg)
set(COMP_SYSTEMVIEW_DIR   ${CMAKE_SOURCE_DIR}/components/systemview)
set(COMP_UTILS_DIR        ${CMAKE_SOURCE_DIR}/components/utils)
set(COMP_WIFI_DIR         ${CMAKE_SOURCE_DIR}/components/wifi)
set(COMP_PHONY_DIR        ${CMAKE_SOURCE_DIR}/components/phony)

################################################################################
#############################    user project    ###############################
################################################################################
# NOTE: header path MUST be provided whether systemview enabled or disabled.
include_directories(${COMP_SYSTEMVIEW_DIR}/Config)
include_directories(${COMP_SYSTEMVIEW_DIR}/Sample/FreeRTOSV9)
include_directories(${COMP_SYSTEMVIEW_DIR}/SEGGER)

include(${CMAKE_SOURCE_DIR}/project/${USER_PROJECT}/gcc/gcc-flags.cmake)
add_subdirectory(${CMAKE_SOURCE_DIR}/project/${USER_PROJECT})

#--------------------------   systemview settings   ----------------------------
if(COMP_SYSTEMVIEW_SUPPORT)
  add_compile_definitions(SYSTEMVIEW_ENABLED)
endif(COMP_SYSTEMVIEW_SUPPORT)
